package com.xingyun.di.module;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jess.arms.di.scope.ActivityScope;
import com.xingyun.app.data.entity.TodayArticleResponse;
import com.xingyun.mvp.contract.MainPagerContract;
import com.xingyun.mvp.model.MainPagerModel;
import com.xingyun.mvp.ui.home.adapter.MainPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import dagger.Module;
import dagger.Provides;


@Module
public class MainPagerModule {
    private MainPagerContract.View view;

    /**
     * 构建MainPagerModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public MainPagerModule(MainPagerContract.View view) {
        this.view = view;
    }

    @ActivityScope
    @Provides
    MainPagerContract.View provideMainPagerView() {
        return this.view;
    }

    @ActivityScope
    @Provides
    MainPagerContract.Model provideMainPagerModel(MainPagerModel model) {
        return model;
    }

    @ActivityScope
    @Provides
    RecyclerView.LayoutManager provideLayoutManager() {
        return new GridLayoutManager(view.getActivity(), 1);
    }

    @ActivityScope
    @Provides
    List<TodayArticleResponse.DataBean> provideDataBeanList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    MainPagerAdapter provideMainPagerAdapter(List<TodayArticleResponse.DataBean> list){
        return new MainPagerAdapter(list);
    }
}
